<template>
	<view>
		<button @click="hLogin">一键登录</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			async hLogin() {
				console.log('登录')
				const { code } = await uni.login()
				// 拿到当前登录在信息
				const {encryptedData, rawData, iv, signature } = await uni.getUserInfo()
				
				const {data} = await this.$request({
					url: 'users/wxlogin',
					method: 'post',
					data: {
						encryptedData,
						rawData,
						iv,
						signature,
						code,
					}
				})
				console.log('登录的结果', data)
				uni.setStorageSync('token', data.token)
				uni.navigateBack()
			}
		}
	}
</script>

<style>

</style>
